<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
if(!$_POST)
{
	if(($adc->getCurrentAdBrandId() > 0) && ($adc->getAdModels()))
	{
		foreach($adc->getAdModels() as $item)
		{
			?>
			<tr class="items">
				<td class="first center"><?php echo $item->getId(); ?></td>
				<td>
					<input type="hidden" name="Id[]" value="<?php echo $item->getId(); ?>" />
					<div style="display:none;"><?php echo $item; ?></div>
					<input class="select_list" type="checkbox" name="selected[]" value="<?php echo $item->getId(); ?>" />
				</td>
				<td><input class="medium" name="Title[]" type="text" value="<?php echo $item->getTitle() ?>" maxlength="80" /></td>
				<td>
					<select class="medium" name="BrandId[]" onchange="submit();">
						<?php 
						echo '<option value="0" '.$txt->getIsSelectedHTML($item->getBrandId(), 0) .'>'.ucfirst($txt->getWord('all')).'</option>';
						$adc->setFrontend(1);
						if($adc->getAdBrands())
						{
							foreach($adc->getAdBrands() as $adbrand)
							{ 
								if($item->getTypeId() > 0)
								{
									if($item->getTypeId() == $adbrand->getTypeId())
									{ echo '<option value="'.$adbrand->getId().'" '.$txt->getIsSelectedHTML($item->getBrandId(), $adbrand->getId()) .'>'.$adbrand->getTitle().'</option>'; }
								}
								else
								{ echo '<option value="'.$adbrand->getId().'" '.$txt->getIsSelectedHTML($item->getBrandId(), $adbrand->getId()) .'>'.$adbrand->getTitle().'</option>'; }
							}
						}
						$adc->setFrontend(0);
						?>
					</select>
				</td>
                <td><input class="small" name="Year[]" type="text" value="<?php echo $item->getYear() ?>" maxlength="4" /></td>
                <td><input class="small" name="YearEnd[]" type="text" value="<?php echo $item->getYearEnd() ?>" maxlength="4" /></td>
				<td>
					<?php echo $commander->getActivationFieldsObjectAjax($item); ?>
					<input type="hidden" name="Active[]" value="<?php echo $item->getActive(); ?>" />
				</td>
				<td class="last center">
				<img title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('ad_type')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteDialog(<?php echo $item->getId(); ?>);" />
				</td>
			</tr>
			<?php
		}
	}
	else
	{
		?>
		<tr class="items">
			<td class="first center">0</td>
			<td class="center"><input class="select_list" type="checkbox" name="selected[]" value="0" /></td>
			<td><?php echo ucfirst($txt->getWord('no_items')); ?></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td class="last center">&nbsp;</td>
		</tr>
		<?php
	}
}
?>